using Tools.Domain.Common.StateMachine;
using Webshop20.Domain.Common;
using Webshop20.Domain.Orders.Core;

namespace Webshop20.Domain.Orders.Processes
{
    public class OrderProcess : Entity, IStateContext, IOrderProcess
    {
        public virtual IState CurrentOrderState { get; private set; }
        public virtual Order OrderInProgress { get; private set; }
        
        public OrderProcess(){}

        public OrderProcess(Order orderInProgress, IState orderState)
        {
            CurrentOrderState = orderState;
            OrderInProgress = orderInProgress;
        }

        public virtual void Fire(IStateEvent currentEvent)
        {
            CurrentOrderState.HandleEvent(currentEvent, this);
        }

        public virtual void ChangeState(IState newState)
        {
            CurrentOrderState = newState;
        }
    }
}